//
//  UIView+someMethods.m
//  BKJ
//
//  Created by 吴涛 on 15/12/30.
//  Copyright © 2015年 贝壳家iOS. All rights reserved.
//

#import "UIView+someMethods.h"

@implementation UIView (someMethods)

+ (instancetype)lineView{
  UIView *lineview = [UIView new];
  lineview.backgroundColor = [UIColor hexStringToColor:@"#cccccc"];
  return lineview;
}

+ (instancetype)xlineView{
  UIView *view = [UIView new];
  
  CAShapeLayer *shapeLayer = [CAShapeLayer layer];
  
//  [shapeLayer setBounds:view.frame];
  shapeLayer.frame = view.frame;
  
  [shapeLayer setPosition:view.center];
  
  [shapeLayer setFillColor:[[UIColor clearColor] CGColor]];
  
  // 设置虚线颜色为blackColor
  
  [shapeLayer setStrokeColor:[[UIColor blackColor] CGColor]];
  
  [shapeLayer setStrokeColor:[[UIColor colorWithRed:223/255.0 green:223/255.0 blue:223/255.0 alpha:1.0f] CGColor]];
  
  
  
  // 3.0f设置虚线的宽度
  
  [shapeLayer setLineWidth:1.0f];
  
  [shapeLayer setLineJoin:kCALineJoinRound];
  
  
  
  // 3=线的宽度 1=每条线的间距
  
  [shapeLayer setLineDashPattern:
   
   [NSArray arrayWithObjects:[NSNumber numberWithInt:3],
    
    [NSNumber numberWithInt:1],nil]];
  
  
  
  // Setup the path
  
  CGMutablePathRef path = CGPathCreateMutable();
  
  CGPathMoveToPoint(path, NULL, 2, 0);
  
  CGPathAddLineToPoint(path, NULL, SCREEN_WIDTH-2,0);
  
  
  
  // Setup the path
  
  CGMutablePathRef path1 = CGPathCreateMutable();
  
  // 0,10代表初始坐标的x，y
  
  // 320,10代表初始坐标的x，y
  
  CGPathMoveToPoint(path1, NULL, 2, 0);
  
  CGPathAddLineToPoint(path1, NULL, SCREEN_WIDTH-2,0);
  
  
  
  [shapeLayer setPath:path];
  
  CGPathRelease(path1);
  
  
  
  // 可以把self改成任何你想要的UIView, 下图演示就是放到UITableViewCell中的
  
  [[view layer] addSublayer:shapeLayer];
  
  return view;
}



@end
